package xyc.szk.web.servlet.config;
/*
 * @Description:
 * @Author: 山志凯
 * @Date: 2021-03-17
 * @Time: 09:10
 */
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;

@WebServlet(value = "/config02") //不能使用

public class ConfigServlet02 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ServletConfig config = this.getServletConfig(); //它是被tomcat服务器实例化的
        PrintWriter pw = resp.getWriter();

        //读取所有的初始化参数
        String value = config.getInitParameter("username"); //获取配置参数中name对应的value
        pw.print(value);
    }
}
